﻿using Domain.Entitys;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EFCore
{
    internal class HFContext:DbContext
    {
        /// <summary>
        /// 配置链接字符串
        /// </summary>
        /// <param name="optionsBuilder"></param>
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
			//链接字符串
			string connStr = "Data Source=.;Initial Catalog=HR_DB;Integrated Security=True;Connect Timeout=30;Encrypt=False;";
			//string connStr = "Data Source=KING;Initial Catalog=HR;Integrated Security=True;Connect Timeout=30;Encrypt=false;pooling=true;";
			optionsBuilder.UseSqlServer(connStr);
        }

        /// <summary>
        /// 读取配置类
        /// </summary>
        /// <param name="modelBuilder"></param>
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            // 显式配置 SS 实体
            modelBuilder.Entity<HF>(entity =>
            {
                entity.ToTable("HF");
                // 配置其他属性...
            });
        }

        public DbSet<HF> HFs { get; set; }
    }
}
